class CC {
  public bar: string = 'hello';

  public foo() {
    console.info('foo');
  }
}

function getInstance(): CC | undefined {
  return new CC();
}

const instance = getInstance();
console.info(`${instance?.bar!}`);
instance?.foo()!;

foo?.bar!;
foo?.bar()!;

// github
foo?.bar!;
foo?.['bar']!;
foo?.bar()!;
foo.bar?.()!;
(foo?.bar)!.baz
(foo?.bar!)
(foo?.bar!)()
(foo?.bar)!().baz    //
(foo?.bar)!     //
(foo?.bar)!()    ///